class App { constructor( canvasId ) { this.cc = document.getElementById( canvasId ).getContext( "2d" ); this.cc.tmp = new Object(); this.cc.tmp.width = this.cc.canvas.width; this.cc.tmp.height = this.cc.canvas.height; } start() { this.timerId = setInterval( this.frame.bind( this ), 100 ); } stop() { clearInterval( this.timerId ); } frame() { this.draw( this.cc ); } draw( cc ) { cc.fillStyle = "gray"; cc.fillRect( 0, 0, cc.tmp.width, cc.tmp.height ); cc.beginPath(); cc.arc( cc.tmp.width / 2, cc.tmp.height / 2, 100, 0, 6.28, false ); cc.closePath(); cc.stroke(); cc.beginPath(); cc.moveTo( 0, 0 ); cc.lineTo( cc.tmp.width, cc.tmp.height ); cc.closePath(); cc.stroke(); } }